package src.render;

import src.entity.Player;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;

public class playerDraw {
    public static void draw(Graphics g, java.util.List<Player> players){
        for (Player player : players) {
            Image originalImage = new ImageIcon("src/resource/img/human33_ak.png").getImage();
            Graphics2D g2d = (Graphics2D) g;

            // 设置缩放比例（例如0.5表示缩小为50%）
            double scale = 0.5;

            // 保存原始变换
            AffineTransform oldTransform = g2d.getTransform();

            // 应用缩放变换
            g2d.scale(scale, scale);

            // 绘制图像，此处坐标可能需要调整
            g2d.drawImage(
                    originalImage,
                    (int) (player.getX() / scale),  // 调整X坐标
                    (int) (player.getY() / scale),  // 调整Y坐标
                    null
            );

            g.setColor(Color.yellow);
            Font font = new Font("微软雅黑", Font.BOLD, 30);
            g.setFont(font);
            g.drawString("Player" + player.getId() + "@" + player.getScore(),
                    (int) ((player.getX() - 30) / scale), (int) ((player.getY() - 10) / scale));

            // 恢复原始变换
            g2d.setTransform(oldTransform);
        }
    }
}
